home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-21 | 3.3 KB | 104 lines | [TEXT/edF6] |
- includeh mac_traps_68k.def *header file for trap names
- includeh ls_68k_macros.def *header file of Fantasm standard macros
- ******************************************
- *A very quick example for Fantasm V4 *
- *Opens a window and prints hello in the *
- *three primary colours. *
- *ISA: 68k *
- *©Lightsoft 1996 *
- ******************************************
- Hello_world:
- **First, initialise the Macintosh
- LEA quickdraw_globals(PC),A0 *QUICK DRAW WORK SPACE
- LEA 202(A0),A0 *ADD 202 TO A0 QUICKLY
- MOVE.L A0,-(SP)
- DC.W _INITGRAF INIT GRAPHICS
- DC.W _INITFONTS INIT FONTS
- MOVEQ #-1,D0
- DC.W _FLUSHEVENTS FLUSHEVENTS NEEDS PARAMETER IN DO
- DC.W _INITWINDOWS INIT WINDOWS
- DC.W _INITMENUS *INIT MENUS
- CLR.L -(SP)
- DC.W _INITDIALOGS *INIT DIALOGS
- DC.W _TEINIT *INIT TEXT EDITOR (YES THERES ONE BUILT IN)
- DC.W _INITCURSOR
- **Now, create a window
- **How it appears in C
- **WindowPtr newcwindow(void *wStorage,const Rect *boundsRect,char *title,
- ** Boolean visible,short procID,WindowPtr behind,Boolean goAwayFlag,long refCon);
- clr.l -(sp) *space for the returned WindowPtr
- clr.l -(sp) *wStorage - not used so cleared
- pea our_window_rect(pc) *the windows' dimensions as a rectangle
- pea our_window_title(pc) *the windows title
- move.b #1,-(sp) *1=is visible
- move.w #4,-(sp) *procID, 4 is normal window
- move.l #-1,-(sp) *This window is behind...-1=no window
- move.b #0,-(sp) *no go away
- move.l #0,-(sp) *no refCon
- dc.w _newwindow create a new window
- move.l (sp)+,d7 save window handle
- move.l d7,-(sp)
- dc.w _setport *tell Mac this is current drawing port
-
- move.w #4,-(sp)
- dc.w _textfont *set font to monaco
- move.w #9,-(sp)
- dc.w _textsize *set 9 point size
-
- **Print first hello in red
- pea red(pc)
- dc.w _rgbforecolor *set colour to red
- move.w #13,-(sp) *x position of cursor
- move.w #30,-(sp) *y position of cursor
- dc.w _moveto
- pea hello(pc)
- dc.w _drawstring
-
- **Print second hello in green
- pea green(pc)
- dc.w _rgbforecolor *set colour to green
- move.w #13,-(sp) *x position of cursor
- move.w #45,-(sp) *y position of cursor
- dc.w _moveto
- pea hello(pc)
- dc.w _drawstring
-
- **And finally, the third hello in blue
- pea blue(pc)
- dc.w _rgbforecolor *set colour to blue
- move.w #13,-(sp) *x position of cursor
- move.w #60,-(sp) *y position of cursor
- dc.w _moveto
- pea hello(pc)
- dc.w _drawstring
-
- moveq #5,d5
- bsr wait_d0secs *wait 5 seconds
- rts_ "Hello_world" *terminate prog with rts_ macro (generates macsbug label)
-
- **Subroutines follow
- **Wait_d0secs delays by d5 seconds
- wait_d0secs:
- muls #60,d5 *Seconds times ticks in a second (60)
- clr.l -(sp)
- dc.w _tickcount *get current time as a tickcount in d7
- move.l (sp)+,d7
- add.l d5,d7 *add on seconds to get end time
- wait_loop:
- clr.l -(sp)
- dc.w _tickcount
- cmp.l (sp)+,d7 *get current tickcount and compare with end time
- bgt.s wait_loop *if end time is greater than current, wait.
- rts_ "Wait_d0secs" *macsbug label for this routine
-
- **Data follows
- quickdraw_globals: ds.b 210 *210 bytes for quickdraw
- our_window_rect: dc.w 100,100,200,200 *top,left,bottom,right
- ; align off
- ;our_window_title: pstring "Fantasm4" *Window title as a Pascal string
- our_window_title: dc.b 8,"Fantasm4"
- red: dc.w 0xffff,0,0 *colours as 16 bits rgb
- green: dc.w 0,0xffff,0
- blue: dc.w 0,0,0xffff
- hello: pstring "Hello world" *text as a pascal string (pstring is a macro)
-